package com.dm0858.bianmin.ui.activity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebViewClient;

import com.dm0858.bianmin.R;
import com.dm0858.bianmin.databinding.ActivityLivingPaymentBinding;
import com.dm0858.bianmin.databinding.ActivityTravelBookingBinding;
import com.dm0858.bianmin.mine.base.BaseActivity;

/**
 * @author 迪迪丶Sir
 * @description
 * @e-mail asd969709719@qq.com
 * @since 2020-05-24
 **/
public class TravelBookingActivity extends BaseActivity implements View.OnClickListener{

    private ActivityTravelBookingBinding binding;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
    }

    @Override
    protected void initView() {
        binding = DataBindingUtil.setContentView(this,R.layout.activity_travel_booking);
        binding.setOnClick(this);
        initData();
    }

    @Override
    protected void initData() {
        WebSettings webSettings = binding.webView.getSettings();
        //允许使用js
        webSettings.setJavaScriptEnabled(true);
        //不支持屏幕缩放
        webSettings.setSupportZoom(false);
        webSettings.setBuiltInZoomControls(false);
        //不显示webview缩放按钮
        webSettings.setDisplayZoomControls(false);
        binding.webView.setWebViewClient(new WebViewClient());
        binding.webView.loadUrl("http://m.ctrip.com/html5/");

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.img_back:
                onBackPressed();
                break;
        }
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK && binding.webView.canGoBack()) {
            binding.webView.goBack();// 返回前一个页面
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
}